package com.example.demo.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class StockIndexUtil {
    /**
     * 获取当前量比 及当日分钟成交量/十日平均美分钟成交量
     * @param currVolume
     * @param averVolume10
     * @return
     */
    public static double getUnitTurnoverRatio(String currVolume, String averVolume10){
        long currVolumeDouble = Long.parseLong(currVolume);
        long aver10Double = Long.parseLong(averVolume10);

        //6.5*60
        return (currVolumeDouble/getUSOpenedMins()) / (aver10Double/60.00/6.50);
    }

    /**
     * 获取美股开盘分钟数
     * @return
     */
    public static double getUSOpenedMins(){
        try {
            String baseTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date(System.currentTimeMillis()-8*3600*1000)) + " 22:30:00";
            long baseTimeMIlli = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(baseTime).getTime();
            long currTime = System.currentTimeMillis();

            return (currTime - baseTimeMIlli)/1000.00/60.00;

        } catch (ParseException e) {
            e.printStackTrace();
        }
        return 0.00;
    }


    public static void main(String[] args) {
        System.out.println(20/60.00);
    }
}
